var a = getApp();

Page({
    data: {
        keyword: "",
        list: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(a) {
        this.search();
    },
    search: function() {
        var t = this;
        this.data.isLoadMore = !0, this.data.page = 1, this.data.total_page = 0;
        var i = a.getNetAddresss("plugin.commission-activity.api.index.activity-search");
        a._postNetWork({
            url: i,
            showToastIn: !1,
            data: {
                page: this.data.page,
                keyword: this.data.keyword
            },
            success: function(a) {
                var i = a.data;
                if (1 == i.result) {
                    var e = i.data;
                    t.setData({
                        list: e.data,
                        page: e.current_page,
                        total_page: e.last_page
                    });
                } else wx.showToast({
                    icon: "none",
                    title: i.msg,
                    duration: 1500
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    },
    searchConfirm: function() {
        this.search();
    },
    keywordInp: function(a) {
        var t = a.detail.value;
        this.setData({
            keyword: t
        });
    },
    gotoDetail: function(a) {
        var t = a.currentTarget.dataset.index, i = this.data.list[t].id;
        wx.navigateTo({
            url: "/packageB/member/distribution_queue/DistributionActivityDetail/DistributionActivityDetail?id=" + i
        });
    },
    _getMoreData: function() {
        var t = this, i = {
            page: this.data.page,
            keyword: this.data.keyword
        }, e = "";
        t.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        e = a.getNetAddresss("plugin.commission-activity.api.index.activity-search"), a._postNetWork({
            url: e,
            showToastIn: !1,
            data: i,
            success: function(a) {
                var i = a.data;
                1 == i.result ? t.setData({
                    isLoadMore: !0,
                    list: t.data.list.concat(i.data.data)
                }) : t.setData({
                    page: t.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        }));
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});